{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 3. pandas数据处理作业"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "3.1 读取excel数据并进行抽样resample()\n",
    "\n",
    "只保留data中的open，获取data的数据类型与后5个值："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "                      close    high     low    open    volume\n",
      "datetime                                                     \n",
      "2017-01-03 15:00:00  115.99  117.06  115.14  115.43  16232125\n",
      "2017-01-04 15:00:00  116.28  116.42  115.21  115.99  29656234\n",
      "2017-01-05 15:00:00  116.07  116.64  115.64  116.07  26436646\n",
      "2017-01-06 15:00:00  115.21  116.07  114.86  116.07  17195598\n",
      "2017-01-09 15:00:00  115.35  115.99  114.86  115.64  14908745\n",
      "2017-01-10 15:00:00  115.28  115.64  114.93  115.21   7996636\n",
      "2017-01-11 15:00:00  115.07  115.64  115.00  115.64   9166532\n",
      "2017-01-12 15:00:00  114.78  115.35  114.71  115.21   8295650\n",
      "2017-01-13 15:00:00  115.85  115.99  114.64  114.64  19024943\n",
      "2017-01-16 15:00:00  117.92  118.20  114.64  115.57  53249124\n",
      "2017-01-17 15:00:00  116.85  117.77  116.56  117.21  12555292\n",
      "2017-01-18 15:00:00  117.42  117.85  116.49  116.92  11478663\n",
      "2017-01-19 15:00:00  117.77  118.49  116.99  116.99  12180687\n",
      "2017-01-20 15:00:00  118.06  118.63  117.49  118.06  14285968\n",
      "2017-01-23 15:00:00  117.99  118.84  117.56  118.63  14615740\n",
      "2017-01-24 15:00:00  118.91  118.91  118.06  118.06  14985241\n",
      "2017-01-25 15:00:00  118.91  119.20  118.27  118.84  11284869\n",
      "2017-01-26 15:00:00  119.41  119.91  118.27  118.84   8602907\n",
      "2017-02-03 15:00:00  118.42  119.98  118.34  119.77   8171489\n",
      "2017-02-06 15:00:00  118.63  119.48  118.63  119.27  13455250\n",
      "2017-02-07 15:00:00  118.77  119.20  118.42  118.56  14757284\n",
      "2017-02-08 15:00:00  118.63  118.84  117.77  118.42  11238767\n",
      "2017-02-09 15:00:00  119.06  119.41  118.13  118.77  11393034\n",
      "2017-02-10 15:00:00  119.48  119.91  118.91  119.34  13983062\n",
      "2017-02-13 15:00:00  119.98  120.34  119.48  120.20  19992372\n",
      "2017-02-14 15:00:00  119.34  120.20  119.20  120.12  12987135\n",
      "2017-02-15 15:00:00  119.98  120.55  119.27  119.77  25687112\n",
      "2017-02-16 15:00:00  119.48  120.41  119.34  120.20  16325732\n",
      "2017-02-17 15:00:00  118.56  119.77  118.13  119.48  13863642\n",
      "2017-02-20 15:00:00  120.55  120.91  118.34  118.34  29915560\n",
      "...                     ...     ...     ...     ...       ...\n",
      "2017-10-10 15:00:00  122.81  122.81  121.78  122.44  13475400\n",
      "2017-10-11 15:00:00  122.44  122.91  122.16  122.34   9654900\n",
      "2017-10-12 15:00:00  122.34  122.72  121.59  122.34   8363600\n",
      "2017-10-13 15:00:00  121.31  122.62  121.22  122.16  11271700\n",
      "2017-10-16 15:00:00  122.25  122.44  121.31  121.59  11832600\n",
      "2017-10-17 15:00:00  121.78  122.44  121.41  122.16   7934100\n",
      "2017-10-18 15:00:00  122.53  122.72  121.22  121.87  22599700\n",
      "2017-10-19 15:00:00  123.09  123.37  121.69  122.25  28931900\n",
      "2017-10-20 15:00:00  121.97  122.81  121.97  122.53   8716900\n",
      "2017-10-23 15:00:00  120.37  122.16  120.28  122.06  15590300\n",
      "2017-10-24 15:00:00  120.56  121.41  120.19  120.37  12571800\n",
      "2017-10-25 15:00:00  120.94  121.31  120.19  120.56  10200400\n",
      "2017-10-26 15:00:00  120.19  120.75  119.81  120.75  12938000\n",
      "2017-10-27 15:00:00  120.47  121.31  120.19  120.37  15482700\n",
      "2017-10-30 15:00:00  119.06  120.19  118.03  120.19  37086800\n",
      "2017-10-31 15:00:00  118.22  118.69  117.94  118.22   9330200\n",
      "2017-11-01 15:00:00  117.56  119.25  117.47  118.12  16948000\n",
      "2017-11-02 15:00:00  117.47  117.75  116.53  117.37  23219200\n",
      "2017-11-03 15:00:00  117.94  118.12  116.53  117.47  15786000\n",
      "2017-11-06 15:00:00  116.91  117.56  116.72  117.56   9785200\n",
      "2017-11-07 15:00:00  117.56  118.12  116.34  116.91  19003800\n",
      "2017-11-08 15:00:00  117.94  118.87  117.19  117.47  18500100\n",
      "2017-11-09 15:00:00  117.66  118.41  117.47  117.84   8739900\n",
      "2017-11-10 15:00:00  118.41  118.41  116.81  117.56  24748600\n",
      "2017-11-13 15:00:00  120.00  120.47  118.41  118.59  41250100\n",
      "2017-11-14 15:00:00  118.12  119.72  117.94  119.62  17172100\n",
      "2017-11-15 15:00:00  118.12  118.41  117.66  117.84  14029600\n",
      "2017-11-16 15:00:00  116.16  117.75  116.06  117.75  18042800\n",
      "2017-11-17 15:00:00  119.81  120.00  116.25  116.25  53475100\n",
      "2017-11-20 15:00:00  120.47  120.56  118.22  118.97  29413900\n",
      "\n",
      "[215 rows x 5 columns]\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "datetime\n",
       "2017-11-14 15:00:00    119.62\n",
       "2017-11-15 15:00:00    117.84\n",
       "2017-11-16 15:00:00    117.75\n",
       "2017-11-17 15:00:00    116.25\n",
       "2017-11-20 15:00:00    118.97\n",
       "Name: open, dtype: float64"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "3.2 表示在【0-31】这32个数字中分成8行4列  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[ 0  1  2  3]\n",
      " [ 4  5  6  7]\n",
      " [ 8  9 10 11]\n",
      " [12 13 14 15]\n",
      " [16 17 18 19]\n",
      " [20 21 22 23]\n",
      " [24 25 26 27]\n",
      " [28 29 30 31]]\n"
     ]
    }
   ],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "3.3 将第5个到第7个改为12  \n",
    "arr=np.arange(10)  最后输出结果为[ 0  1  2  3  4 12 12 12  8  9]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[ 0  1  2  3  4 12 12 12  8  9]\n"
     ]
    }
   ],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "3.4如何方便的计算两个时间的差，如两个时间相差几天，几小时等，写出代码，列出式子"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
